#include "mainwindow.h"
#include <QApplication>
#include <QSystemTrayIcon>
#include "installprogram.h"
#include <QMenu>
#include <QObject>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    a.setApplicationVersion("1.0.0");
    a.setApplicationName("Wine 运行器附属虚拟机（Windows 端）");
    // 托盘图标
    QSystemTrayIcon *icon = new QSystemTrayIcon();
    icon->setIcon(QIcon(":/icon/deepin-wine-runner-virtual-machine.svg"));
    // 创建菜单
    QMenu *menu = new QMenu();
    QAction *update = new QAction("更新这个程序");
    QAction *about = new QAction("关于这个程序");
    QAction *exitProgram = new QAction("退出");
    menu->addAction(update);
    menu->addAction(about);
    menu->addSeparator();
    menu->addAction(exitProgram);
    // 响应事件（connect）
    QObject::connect(about, &QAction::triggered, &a, [&a](){
        MainWindow *w = new MainWindow();
        w->show();
    });
    QObject::connect(exitProgram, &QAction::triggered, &a, [&a](){
        a.exit();
    });
    icon->setContextMenu(menu);
    icon->show();
    icon->showMessage("提示", "程序有新版本可以更新", QSystemTrayIcon::MessageIcon::Information, 99999);
    // 事件
    installprogram *program = new installprogram();
    return a.exec();
}
